﻿using System;
using System.Collections.Generic;
using NGinnBPM.Lib.Interfaces.Worklist;
using System.Text;

namespace NGinnBPM.Services.Worklist
{
    /// <summary>
    /// Remoted resource manager
    /// </summary>
    public class RemoteResourceManager : IUserDataRepository
    {
        public string ServiceUrl { get; set; }
        #region IUserDataRepository Members

        private IUserDataRepository _srv;

        private IUserDataRepository Service
        {
            get
            {
                if (_srv != null) return _srv;
                _srv = (IUserDataRepository) Activator.GetObject(typeof(IUserDataRepository), ServiceUrl);
                return _srv;
            }
        }

        public bool IsValidResourceId(string rcId)
        {
            return Service.IsValidResourceId(rcId);
        }

        public string SelectPerson(string query)
        {
            return Service.SelectPerson(query);
        }

        public string SelectGroup(string query)
        {
            return Service.SelectGroup(query);
        }

        #endregion

        public override string ToString()
        {
            return string.Format("RemoteResourceManager: {0}", ServiceUrl);
        }
    }
}
